import { z } from "zod";

// 定义一个 Schema
const userSchema = z.object({
  name: z.string(),
  age: z.number(),
});

const user = {
  name: "张三",
};

const result = userSchema.safeParse(user);

if (result.success) {
  console.log("合法的数据", result.data);
} else {
  console.log("校验失败", result.error.format());
}
